﻿using Mall.Application;
using Mall.Core;
using Mall.Core.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Mall.Web.Entry.Controllers
{
    [Authorize]
    public class RoleController : Controller
    {
        #region Field
        private readonly IRoleService _roleService;
        #endregion

        #region Ctor
        public RoleController(IRoleService roleService)
        {
            _roleService = roleService;
        }
        #endregion

        #region Index
        [HttpGet]
        public IActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public IActionResult Index(RoleDtoInput input)
        {
            var page = _roleService.GetPagedList(input);
            return Json(new LayuiResult<Role>
            {
                Code = "0",
                Msg = "",
                Data = page.Items,
                Count = page.TotalCount
            });

        }
        #endregion

        #region Grant
        public IActionResult GrantResource(int id)
        {   
            return View();
        }
        #endregion
    }
}
